﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Windows;
using System.Windows.Controls;
using System.Windows.Data;
using System.Windows.Documents;
using System.Windows.Input;
using System.Windows.Media;
using System.Windows.Media.Imaging;
using System.Windows.Shapes;

namespace EmotionPlotter
{
    /// <summary>
    /// Interaction logic for AddEmotion.xaml
    /// </summary>
    public partial class AddEmotion : Window
    {
        public AddEmotion()
        {
            InitializeComponent();

            // test

            foreach (String[][] EmsInfs in emotionsAntiEmotions)
            {

                foreach (String[] Ems in EmsInfs)
                {
                    String N_or_P = Ems[0];

                }

            }


           // foreach (String[][] EmsInfs in emotionsAntiEmotions)
           // {
           //     EmotionLevels el = new EmotionLevels();
                
                //#error Pair of emotions should be started from.
                // foreach (String[] Ems in EmsInfs)
                //{ 

             //   el.EmotionName = EmsInfs[1][1].ToString();
             //   el.NegativeEmotionName = EmsInfs[5][0].ToString();
             //   el.PositiveEmotionName = EmsInfs[1][0].ToString();
             //   CollectionPtr.AddEmotion(el);
             //   AddedEmotions.Add(el.EmotionName);
              //  comboBox1.Items.Clear();
             //   comboBox2.Items.Clear();
             //   label1.Content = "< --- All added.";
                //}

            //}
        }

        enum Emotions
        {
            Optimism,
            Love,
            Submission,
            Awe,
            Disappointment,
            Remorse,
            Contempt,
            Aggression
        };


        List<String> AddedEmotions = new List<string>();
        String[][] emotionsAntiEmotion = new string[][] 
        {
                //new String[] {  "Optimism"          ,   "Anticipation"  ,   "Joy"           },
                new String[] {  "Optimism"          ,   "Serenity"      ,   "Interest"      },
                new String[] {  "Love"	            ,   "Joy"           ,   "Trust"         },
                new String[] {  "Submission"	    ,   "Trust"         ,   "Fear"          },
                new String[] {  "Awe"	            ,   "Fear"          ,   "Surprise"      },
                new String[] {  "Disappointment"	,   "Surprise"      ,   "Sadness"       },
                new String[] {  "Remorse"	        ,   "Sadness"       ,   "Disgust"       },
                new String[] {  "Contempt"	        ,   "Disgust"       ,   "Anger"         },
                new String[] {  "Aggression"	    ,   "Anger"         ,   "Anticipation"  }
        };

        //String[][][] emotionsAntiEmotion2 = new string[][][]
        //    {
        //            new String[][] {new String[]{"Optimism"        ,   "Serenity + Interest" },new String[]{"Disapproval", "" } },
        //            new String[] {"Love"	        ,   "Joy + Trust"           ,   "Remorse"        , "" },
        //            new String[] {"Submission"	    ,   "Trust + Fear"	        ,   "Contempt"       , "" },
        //            new String[] {"Awe"	            ,   "Fear + Surprise"       ,   "Aggressiveness" , "" },
        //            new String[] {"Disappointment"	,   "Surprise + Sadness"    ,   "Optimism"       , "" },
        //            new String[] {"Remorse"	        ,   "Sadness + Disgust"	    ,   "Love"           , "" },
        //            new String[] {"Contempt"	    ,   "Disgust + Anger"	    ,   "Submission"     , "" },
        //            new String[] {"Aggression"	    ,   "Anger + Anticipation"  ,   "Awe"            , "" }
        //    };

        //-250 to 250
        // 100, +50, +50, +50

        String[][][] emotionsAntiEmotions = new string[][][] 
            { 
                   new String[][] 
                   {  
                        new String[]{   "Negative"     },
                        new String[]{   "Terror"       ,   "Fear"      ,   "Apprehension"  },
                        new String[]{   "Worst"        ,   "OK"        ,   "Bad"           },
                        new String[]{   "-100"         ,   "-150"      ,   "-200"          ,    "-50"   },
                        new String[]{   "1"            ,  "0", "+337.5"    },
                        new String[]{   "Rage"         } 
                    } ,
                    
                    new String[][] 
                    {  
                        new String[]{   "Positive"      },
                        new String[]{   "Admiration"    ,   "Trust"     ,   "Acceptance"    }, 
                        new String[]{   "Best"          ,   "Nice"      ,   "Awsm"          },
                        new String[]{   "100"           ,   "150"       ,   "200"           ,   "50"    },
                        new String[]{   "2"             ,   "45","+022.5"    }, 
                        new String[]{   "Loathing"      }
                    } ,

                    new String[][] 
                    {
                        new String[]{   "Positive"      },
                        new String[]{   "Ecstacy"       ,   "Joy"       ,   "Serenity"      },
                        new String[]{   "Best"          ,   "Nice"      ,   "Awsm"          }, 
                        new String[]{   "100"           ,   "150"       ,   "200"           ,   "50"    },
                        new String[]{   "3"             ,   "90","+067.5"    }, 
                        new String[]{   "Grief"         }
                        
                    } ,

                     new String[][] 
                     {  
                        new String[]{   "Nuetral"       },
                        new String[]{   "Vigilance"     ,   "Anticipation"  ,   "Interest"      },
                        new String[]{   "Worst"         ,   "OK"            ,   "OK"            } , 
                        new String[]{   "100"           ,   "150"           ,   "200"           ,   "50"    },
                        new String[]{   "4"             ,   "135","+112.5"        },  
                        new String[]{   "Amazement"     }
                    } ,

                    new String[][] 
                    { 
                        new String[]{   "Negative"      },
                        new String[]{   "Rage"          ,   "Anger"	        ,   "Annoyance"     },
                        new String[]{   "Worst"         ,   "OK"            ,   "Bad"           },    
                        new String[]{   "-100"          ,   "-150"          ,   "-200"          ,   "-50"   },
                        new String[]{   "5"             ,   "175","+157.5"        }, 
                        new String[]{   "Terror"        }
                    } ,

                    new String[][] 
                    {  
                        new String[]{   "Negative"      },
                        new String[]{   "Loathing"      ,   "Disgust"	    ,   "Boredom"       },
                        new String[]{   "Worst"         ,   "OK"            ,   "Bad"           }, 
                        new String[]{   "-100"          ,   "-150"          ,   "-200"          ,   "-50"   },
                        new String[]{   "6"             ,   "220","+202.5"        }, 
                        new String[]{   "Admiration"    } 
                    } ,
 
                    new String[][] 
                    {  
                        new String[]{   "Negative"      },
                        new String[]{   "Grief"         ,   "Sadness"       ,   "Pensiveness"   },
                        new String[]{   "Worst"         ,   "OK"            ,   "Bad"           },
                        new String[]{   "-100"          ,   "-150"          ,   "-200"          ,   "-50"   },
                        new String[]{   "7"             ,   "265","+247.5"        }, 
                        new String[]{   "Ecstacy"       } 
                    } ,

                    new String[][] 
                    {  
                        new String[]{   "Nuetral"       },
                        new String[]{   "Amazement"     ,   "Surprise"      ,   "Distraction"   },
                        new String[]{   "Best"          ,   "Nice"          ,   "OK"            },
                        new String[]{   "100"           ,   "150"           ,   "200"           ,   "50"    },            
                        new String[]{   "8"             ,   "310","+292.5"        }, 
                        new String[]{   "Vigilance"     } 
                    }
                   
            };

        private void Window_Loaded(object sender, RoutedEventArgs e)
        {
            button2_Click_1(null,null);
            this.Close();
            return;

            foreach (String[] s in emotionsAntiEmotion)
            {
                Boolean addIt = true;

                foreach (String aes in AddedEmotions)
                {
                    if (aes.Contains(s[0]))
                    {
                        addIt = false;
                    }
                }

                if (addIt)
                    comboBox1.Items.Add(s[0]);
            }
        }

        private void comboBox1_SelectionChanged(object sender, SelectionChangedEventArgs e)
        {
            if (null != comboBox1.SelectedItem)

                foreach (String[] s in emotionsAntiEmotion)
                {
                    if (s[0].ToString().Contains(comboBox1.SelectedItem.ToString()))

                        comboBox2.Items.Add(s[1]);
                }
        }

        private void button1_Click(object sender, RoutedEventArgs e)
        {
            try
            {
                EmotionLevels el = new EmotionLevels();
                el.EmotionName = comboBox1.SelectedItem.ToString();
                el.NegativeEmotionName = label1.Content.ToString();
                el.PositiveEmotionName = comboBox2.SelectedItem.ToString();
                CollectionPtr.AddEmotion(el);
                AddedEmotions.Add(el.EmotionName);
                comboBox1.Items.Clear();
                comboBox2.Items.Clear();
                label1.Content = "< --- Make selection.";
                Window_Loaded(null, null);

            }
            catch (Exception)
            {

                //
            }
        }

        private void comboBox2_SelectionChanged(object sender, SelectionChangedEventArgs e)
        {
            if (null != comboBox2.SelectedItem)

                foreach (String[] s in emotionsAntiEmotion)
                {
                    if (s[1].ToString().Contains(comboBox2.SelectedItem.ToString()))
                        label1.Content = "Opposite: " + s[2].ToString();
                }

        }

        /*
         * Human feelings         Feelings	                Opposite
         *  Optimism        Anticipation    + Joy	            Disappointment
            Love	        Joy             + Trust	            Remorse
            Submission	    Trust           + Fear	            Contempt
            Awe	            Fear            + Surprise	        Aggression
            Disappointment	Surprise        + Sadness	        Optimism
            Remorse	        Sadness         + Disgust	        Love
            Contempt	    Disgust         + Anger	            Submission
            Aggression	    Anger           + Anticipation	    Awe
         * */

        public EmotionLevelCollection CollectionPtr { get; set; }

        private void button2_Click(object sender, RoutedEventArgs e)
        {
            button1_Click(null, null);
            this.Hide();
        }

        private void button3_Click(object sender, RoutedEventArgs e)
        {
            this.Hide();
        }

        private void button2_Click_1(object sender, RoutedEventArgs e)
        {


            //foreach (String[][] EmsInfs in emotionsAntiEmotions)
            //{
            //    EmotionLevels el = new EmotionLevels();

            //   // foreach (String[] Ems in EmsInfs)
            //    //{ 
            //    el.EmotionName = EmsInfs[1][0].ToString();
            //    el.NegativeEmotionName = EmsInfs[1][0].ToString();
            //        el.PositiveEmotionName = s[1].ToString();
            //        CollectionPtr.AddEmotion(el);
            //        AddedEmotions.Add(el.EmotionName);
            //        comboBox1.Items.Clear();
            //        comboBox2.Items.Clear();
            //        label1.Content = "< --- All added.";
            //    //}

            //}
            foreach (String[][] EmsInfs in emotionsAntiEmotions)
            {
                EmotionLevels el = new EmotionLevels();
                el.IsNegativeEmotion = EmsInfs[0][0];
                el.EmotionName = EmsInfs[1][1].ToString();
                el.NegativeEmotionName = EmsInfs[5][0].ToString();
                el.PositiveEmotionName = EmsInfs[1][0].ToString();
                float angle = 0;
                float.TryParse(EmsInfs[4][1], out  angle);
                el.Angle = angle;
                CollectionPtr.AddEmotion(el);
                AddedEmotions.Add(el.EmotionName);
                comboBox1.Items.Clear();
                comboBox2.Items.Clear();
                label1.Content = "< --- All added.";
            }
        }
    }
}
